﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>#SingleInstance - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The #SingleInstance directive determines whether a script is allowed to run again when it is already running." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>#SingleInstance</h1>

<p>确定脚本已在运行时是否允许再次运行.</p>

<pre class="Syntax"><span class="func">#SingleInstance</span> <span class="optional">ForceIgnorePromptOff</span></pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>ForceIgnorePromptOff</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>如果省略参数, 则默认为 <em>Force</em>. 要更改此行为, 请指定以下单词之一:</p>
    <p><strong>Force:</strong> 跳过对话框并自动替换旧实例, 效果类似于 <a href="Reload.htm">Reload</a> 函数.</p>  
    <p><strong>Ignore:</strong> 跳过对话框并让旧实例继续运行. 换句话说, 试图启动已经运行的脚本会被忽略.</p>
    <p><strong>Prompt:</strong> 显示一个对话框, 询问是保留旧实例还是用新实例替换它. 如果不使用此指令, 这是默认的行为.</p>
    <p><strong>Off:</strong> 允许一个脚本同时运行多个实例.</p>
  </dd>

</dl>
<h2 id="Remarks">备注</h2>
<p>当使用以下<a href="../Scripts.htm#cmd">命令行开关</a>时, 该指令将被忽略: /force /f /restart /r</p>
<p>AutoHotkey 依赖于脚本<a href="../Program.htm#main-window">主窗口</a>的标题来标识脚本的其他运行实例.</p>

<h2 id="Related">相关</h2>
<p><a href="Reload.htm">Reload</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>#SingleInstance force
#SingleInstance ignore
#SingleInstance off</pre>
</div>

</body>
</html>